<!--
	作者：2575202388@qq.com
	时间：2019年8月6日17:11:48
	描述：书籍管理搜索
-->
<template>
    <div style="width:100%;height:540px;"> 
        <Tetable ref="tdtable" height="450" :columns="columns9" type="post" :paramiters="tj" :serverUrl="serverUrl"></Tetable>
        <edit ref="edit" v-on:reload="load()" :editparam="editparam" :bid="tj.bid"></edit>
    </div> 
</template>
<script>
	import EditDelLook from "./EditDelLook";
	import edit from "./edit";
    export default {
    	name: "bookquestionss",
    	props: {
    		tj:{
    			type: Object
    		},	
    	},
        data () {
            return {
            	serverUrl:"/host/readbook/sjgl/Search_Tm.html",
                columns9: [
                    {
                        type: 'index',
                        width: 60,
                        title: '序号',
                        align: 'center'
                    },{
                        title: '题目内容',
                        width: 200,
                        key: 'TMNR',
                        align: 'center',
                    },{
                        title: '题型',
                        key: 'TXT',
                        width: 60,
                        align: 'center', 
                    },{
                        title: '答案',
                        key: 'ANSWER',
                        align: 'center', 
                    }, {
                        title: 'A',
                        key: 'AD',
                        align: 'center', 
                    },  {
                        title: 'B',
                        key: 'BD',
                        align: 'center', 
                    }, {
                        title: 'C',
                        key: 'CD',
                        align: 'center', 
                    },{
                        title: 'D',
                        key: 'DD',
                        align: 'center', 
                    },  {
                        title: 'E',
                        key: 'ED',
                        align: 'center', 
                    }, {
                        title: 'F',
                        key: 'FD',
                        align: 'center', 
                    }, {
                        title: '操作',
                        key: 'action',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h(EditDelLook, {
                            	on: {
                                    //删除题目
                                    remove: () =>{
										
										if((this.user.permission && this.user.permission.indexOf("1")>-1) || this.user.uname=='admin'){
											const rows=params.row;
											this.remove(rows.QID)
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
                                    	
                                    },
                                    //修改题目
                                    edit: () =>{
										
										if((this.user.permission && this.user.permission.indexOf("1")>-1) || this.user.uname=='admin'){
											const rows=params.row;
											this.editparam={
												qid:rows.QID, 
												tmnr:rows.TMNR, 
												tx:rows.TX+"", 
												answer:rows.ANSWER, 
												ad:rows.AD, 
												bd:rows.BD, 
												cd:rows.CD, 
												dd:rows.DD, 
												ed:rows.ED, 
												fd:rows.FD
											}
											this.$refs.edit.openmodal();
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
                                    	
                                    },
                                    
                                }
                            });
                        }
                    }
                ],
                editparam:{}
            }
        },
        computed: {
			user: function() {
				return this.$store.state.app.user;
			}
		},
		methods: {
			//删除题目
			remove:function(qid){
                this.$Modal.confirm({
                    title: '警告',
                    content: '请确定是否删除！！！',
                    onOk: () => {
                    	//执行删除代码
                    	this.$http.get("/host/readbook/sjgl/del_bookquestion.html?qid="+qid)
						.then(datas => {
							if(datas.result){
								//删除成功 刷新页面
								this.$Message.info('删除成功');
								this.$refs.tdtable.load();
							}else{
								//删除成功 刷新页面
								this.$Message.info(datas.msg);
								this.$refs.tdtable.load();
							}
							
						});
                    }
                });
			},
			
			
			load(){
				this.$refs.tdtable.load();
			},

	    },
		mounted() {
		},
		watch:{
		},
		components: {
			EditDelLook,
			edit
		}
    }
</script>


<style scoped="scoped">
	
	.ivu-table-wrapper {
		border:none;
	}
	
	.toolstipdiv{
		width: '100%';
		overflow: 'hidden';
		textOverflow: 'ellipsis';
		whiteSpace: 'normal';
		wordBreak: 'break-all';
		color:'#fff';
		text-align: center;
	}
	.toolstipdiv:hover{
		background:rgb(63, 193, 201);
	}
	
	.ivu-tooltip-rel label:hover{
		color:#0023FB;
	}
	
	.tablediv{
		height: '40px';
		overflow:'hidden';
		line-height: '40px';
	}
</style>



